package org.ping.Servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.ping.Tool.NewsUtil;

import com.alibaba.fastjson.JSON;

@WebServlet("/newinfo")
public class NewInfoServlet extends HttpServlet{
	private static final long serialVersionUID = 411851053608502786L;
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		//获取客户端的新闻详细ID
		String id = req.getParameter("id");
		String json = JSON.toJSONString(NewsUtil.getNewsUtil().getNewInfo(id));
		//System.out.println(json);
		//推送详细信息到客户端
		PrintWriter pw = resp.getWriter();
		pw.print(json);
		pw.flush();
		pw.close();
		
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req, resp);
	}
}
